{template '_header'}
<div class="page-header">
    当前位置：
    <span class="text-primary">
        {if !empty($item['id'])}编辑{else}添加{/if}标签组 <small>{if !empty($item['id'])}修改【{$item['label']}】{/if}</small>
    </span>
</div>
<div class="page-content">
    <div class="page-sub-toolbar">
        <span class=''>
		{ifp 'goods.label.add'}
            <a class="btn btn-primary btn-sm" href="{php echo webUrl('goods/label/add')}">添加新标签组</a>
		{/if}
	</span>
    </div>
    <form {ife 'goods' $item}action="" method="post"{/if} class="form-horizontal form-validate" enctype="multipart/form-data" >
        <div class="form-group">
            <label class="col-lg control-label">排序</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'goods' $item}
                <input type="text" name="displayorder" class="form-control" value="{$item['displayorder']}" />
                {else}
                <div class='form-control-static'>{$item['displayorder']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label must">标签组名称</label>
            <div class="col-sm-9 col-xs-12">
                {ife 'goods' $item}
                <input type="text" name="label" class="form-control" value="{$item['label']}" data-rule-required="true" />
                {else}
                <div class='form-control-static'>{$item['label']}</div>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">标签</label>
            <div class="col-sm-9 col-xs-12">
                <table class="table table-responsive" style="margin:0;">
                    <tbody id='tbody-items' style="border-top:none;">
                    {loop $labelname $row}
                    <tr>
                        <td>
                            {ifp 'goods.label.edit'}
                            <input type="text" class="form-control" name="labelname[]" value="{$row}" >
                            {else}
                            {$row['labelname']}
                            {/if}
                        </td>
                        <td style="width: 45px;">
                            {ifp 'goods.label.delete'}
                            <a href="javascript:void(0);" class="btn btn-default btn-del btn-op btn-operation" data-confirm="确认删除此标签?">
                                  <span data-toggle="tooltip" data-placement="top" title="" data-original-title="删除">
                                      <i class="icow icow-shanchu1"></i>
                                    </span>
                                </a>
                            {/if}
                        </td>

                    </tr>
                    {/loop}
                    </tbody>
                </table>
                {ifp 'goods.label.edit'}
                <input name="button" type="button" class="btn btn-default" value="添加标签" onclick='addCategory()'>
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label">是否启用</label>
            <div class="col-sm-9 col-xs-12" id="param-items">
                 {ife 'groups.goods' $item}
                <label class="radio-inline">
                    <input type="radio" name='status' value="1" {if $item['status']==1}checked{/if} /> 是
                </label>
                <label class="radio-inline">
                    <input type="radio" name='status' value="0" {if empty($item['status'])}checked{/if} /> 否
                </label>
                    {else}
                 <div class='form-control-static'>{if empty($item['status'])}是{else}否{/if}</div>
                 {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg control-label"></label>
            <div class="col-sm-9 col-xs-12">
                 {ife 'goods.label' $item}
                    <input type="submit" value="提交" class="btn btn-primary"  />
                {/if}
               <a href="{php echo webUrl('goods/label')}" {ifp 'goods.label.add|goods.label.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default">返回列表</a>
            </div>
        </div>
    </form>
</div>
<script>

    {ifp 'goods.label.edit'}
    require(['jquery.ui'],function(){
        $('#tbody-items').sortable();
    })
    {/if}

    function addCategory(){
        var html ='<tr>';
        html+='<td style="width:200px;">';
        html+='<input type="text" class="form-control" name="labelname[]" value="">';
        html+='</td>';

        html+='<td></td></tr>';;
        $('#tbody-items').append(html);
    }
    $(function(){
        $(".btn-del").on("click",function(){
            var $btntr = $(this).parents('tr');
            console.log($btntr);
            tip.confirm('确认删除此标签?',function(){
                $btntr.remove();
            });
        });
    });
</script>
{template '_footer'}